{extend name="base"/}
{block name="title"}
修改支付密码
{/block}
{block name="css"}
<link rel="stylesheet" href="__MOBILE__/css/registered.css"/>

{/block}
{block name="content"}
<div class="header">
        <div class="fanhui">
           <a href="javascript:history.go(-1);"><img src="__MOBILE__/images/fanhui.png" alt=""></a> 
        </div>
        修改支付密码
</div>
        <div class="regInfo">
                <ul>
                    <li>
                        <img src="__MOBILE__/images/shoujihao.png" alt="">
                        <input type="text" placeholder="请输入注册手机号" class="usertell">
                    </li>
                    <li>
                        <img src="__MOBILE__/images/yanzhengma.png" alt="">
                        <input type="text" placeholder="请输入验证码" class="usercode">
                        <p class="getCode">获取验证码</p>
                    </li>
                    <li>
                        <img src="__MOBILE__/images/mima.png" alt="">
                        <input type="password" placeholder="新密码" class="userpass">
                    </li>
                    <li>
                        <img src="__MOBILE__/images/mima.png" alt="">
                        <input type="password" placeholder="确认密码" class="userpassword" >
                    </li>
                </ul>
            </div>
            <div class="restbtn regButton">重置密码</div>
{/block}
{block name="js"}
        <script>
                $('.restbtn').click(function(){
                    var phone= $('.usertell').val();
                    var pwd= $('.userpass').val();
                    var passwordmin= $('.userpassword').val();
                    var code= $('.usercode').val();
                    if($('.usertell').val()==''){
                        msg_alert('请输入您注册的手机号')
                    }else if($('.usercode').val()==''){
                        msg_alert('请输入验证码')
                    }else if($('.userpass').val()==''){
                        msg_alert('请输入新密码')
                    }else if($('.userpassword').val()==''){
                        msg_alert('请再次确认密码')
                    }else{
                        $.post("{:url('/langjinmobile/registered/getPswpay')}",{code:code,phone:phone,pwd:pwd},function(data){
                            console.log(data);
                            if(data.code==1){
                                msg_alert('修改密码成功');
                                //window.location.href = "/langjinmobile/registered/login";
                            }else if(data.code==0){
                                // alert(data.msg);
                                // location.href=data.url;
                                msg_alert_url(data.msg,data.url);

                            }else{
                                msg_alert(data.msg);
                            }   
                        })
                    }
                })


                $('.getCode').click(function(){
        var username = $('.username').val();
            var usertell = $('.usertell').val();
        var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
        if($('.usertell').val()== '' || !myreg.test(usertell)){
            msg_alert('请输入正确的手机号')
                return
        }
        if($(this).text() =='获取验证码'){
            $.post("{:url('/langjinmobile/registered/code')}", {
                        mobile: usertell,
                        type:2
                    }, function (data) {
                        console.log(data);
                        if (data == 1) {
                            var obj = $("#mycode");
                            settime();
                            layer.msg("发送成功");
                        } else if(data == 3){
                            layer.msg("{:lang('请勿重复发送')}");
                        }else if (data == 5) {
                            layer.msg("{:lang('该手机号已经注册')}");

                        }
                    })

            
        }
    })

    function settime(){
        msg_alert('验证码已发送，请注意查收')
            var num = 60;
        var _this = $('.getCode');
        var timer = setInterval(function() {
            num--
            _this.text(num + 'S');
            if(num == 0){
                _this.text('获取验证码');
                clearInterval(timer);
            }
        },1000)
    }



        </script>
{/block}